<template>
  <section class="pageMain">
    <img v-if="image != ''" class="headImg" :src="imgss[0].image" alt="">
    <div class="showTitle">
      <img class="titleBack" src="@/assets/titleBack.png" alt="">
      <div class="mainTitle">NEWS AND INFORMATION</div>
      <div class="subTitle">{{ $t('newDetail.nav') }}</div>
    </div>

    <div class="server">
      <div class="news">
        <div class="news_block">
          <div class="item" v-for="item in newsList" @click="toDetail(item.id)">
            <div class="left">
              <div>{{ item.update_time.slice(5,7) }}/{{ item.update_time.slice(8,10) }}</div>
              <div>{{ item.update_time.slice(0,4) }}</div>
            </div>
            <div class="right">
              <div class="title">{{ item.title }}</div>
              <div class="content">
                {{ item.description }}
              </div>
            </div>
          </div>
        </div>

      </div>

    </div>
    <el-pagination
        background
        @current-change="pageChange"
        class="pagef"
        layout="prev, pager, next"
        :total="total">
    </el-pagination>

  </section>

</template>

<script>
import {getContent, getNewList} from "@/api/new";

export default {
  name: "productClass",
  data: () => ({
    image:'',
    page:1,
    total:200,
    newsList:[]
  }),
  computed:{
    imgss(){
      return this.$store.state.storeThereNavList.filter(item => item.mid == 2)
    }
  },
  created() {
    this.getNavList()
    // console.log(this.$store.state.storeThereNavList)
    let arr = this.$store.state.storeThereNavList
    for (let i = 0; i < arr.length; i++) {
      if (arr[i].mid == 2){
        this.image = arr[i].image
        break;
      }
    }
  },
  methods:{
    pageChange(page){
      // console.log(item)
      this.page = page
      this.getNavList()
    },
    getNavList(){
      getContent({page:this.page,limit:10,mid:2}).then(res => {
        // console.log(res,"nav")
        this.newsList = res.data.data
        this.total = res.data.total
      }).catch(err => {
        // console.log(err)
      })
    },
    toDetail(id){
      this.$router.push({
        name: 'newDetail',
        query:{
          id: id
        }
      },()=>{})
    }
  }
}
</script>


<style scoped lang="less">
.pageMain {

  .headImg {
    width: 100%;
    height: 300px;
  }

  .showTitle {
    padding: 60px;
    box-sizing: content-box;
    position: relative;
    text-align: center;
    height: 126px;
    .titleBack {
      position: absolute;
      left: calc((100% - 30px) / 2);
      width: 30px;
      height: 127px;
    }

    .mainTitle {
      font-weight: 800;
      font-size: 36px;
      color: #333333;
      margin-top: 25px;
    }

    .subTitle {
      color: #00A3E6;
      font-size: 18px;
    }
  }
  .server {
    //padding-top: 145px;
    //margin-bottom: 120px;

    .top1 {
      font-weight: bold;
      font-size: 36px;
      color: #333333;
      text-align: center;
      margin-bottom: 6px;
    }

    .top2 {
      color: #00A3E6;
      font-size: 18px;
      text-align: center;
      margin-bottom: 92px;
    }

    .server_bottom {

      margin: 0 auto;
      display: flex;
      justify-content: space-between;
      width: 1200px;

      .s_i {
        width: 490px;

        .dcontent {
          margin-bottom: 80px;
        }
      }
    }

    //  -----------------------
    .news{
      width: 1200px;
      margin: 0 auto;
      display: flex;
      flex-wrap: wrap;
      //justify-content: space-between;
      .news_block {
        cursor: pointer;
        .item {
          display: inline-block;
          margin-right: 76px;
          margin-top: 52px;
          padding-bottom: 30px;
          width: 562px;
          //display: flex;
          border-bottom: 1px solid #D8D8D8;
          .left {
            width: 60px;
            color: #333333;

            div:nth-child(1) {
              font-size: 22px;
            }

            div:nth-child(2) {
              font-size: 12px;
            }
          }

          .right {
            width: calc(100% - 60px);
            padding-left: 36px;
            .title {
              font-size: 16px;
              color: #333333;
              margin-bottom: 10px;
              width: 100%;
              white-space: nowrap;
              text-overflow: ellipsis;
              overflow: hidden;
              word-break: break-all;
            }

            .content {
              line-height: 24px;
              font-size: 14px;
              color: #666666;
              width: 100%;
              word-break: break-all;
              text-overflow: ellipsis;
              display: -webkit-box;
              -webkit-box-orient: vertical;
              -webkit-line-clamp: 2; /* 这里是超出几行省略 */
              overflow: hidden;
            }
          }

        }
        .item:nth-child(2n){
          margin-right: 0;
        }
      }
    }

  }

  .pagef{
    width: 500px;
    margin: 100px auto;
  }

}



</style>